# Copyright (c) 2025 Huawei Technologies Co., Ltd.
# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
# CANN Open Software License Agreement Version 2.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.

from . import adv
from . import basic
from . import core
from . import fwk

from .basic import __all__ as basic_all
from .core import __all__ as core_all
from .fwk import __all__ as fwk_all


# basic
from .basic.block_sync import (
    data_sync_barrier,
    pipe_barrier,
    set_flag,
    wait_flag,
)
from .basic.common import (
    ascend_is_aic,
    ascend_is_aiv,
    get_hccl_context,
    get_sys_workspace,
    reset_mask,
    set_aipp_functions,
    set_atomic_add,
    set_atomic_max,
    set_atomic_min,
    set_atomic_none,
    set_atomic_type,
    set_hccl_context,
    set_hf32_mode,
    set_hf32_trans_mode,
    set_mask_count,
    set_mask_norm,
    set_mm_layout_transform,
    set_sys_workspace,
    set_vector_mask,
)
from .basic.data_cache import data_cache_clean_and_invalid, get_icache_preload_status, icache_preload
from .basic.data_copy import copy, data_copy, data_copy_pad
from .basic.data_conversion import transpose, trans_data_to_5hd
from .basic.dump_tensor import dump_tensor, printf, print_time_stamp, dump_acc_chk_point
from .basic.scalar import scalar_cast, scalar_get_sff_value
from .basic.sys_var import (
    get_arch_version,
    get_block_idx,
    get_block_num,
    get_data_block_size_in_bytes,
    get_sub_block_num,
    get_program_counter,
    get_system_cycle,
    trap,
)
from .basic.vec_binary import (
    add,
    add_deq_relu,
    add_relu,
    bilinear_interpolation,
    bitwise_and,
    bitwise_or,
    div,
    fused_mul_add,
    fused_mul_add_relu,
    max,
    min,
    mul,
    mul_add_dst,
    mul_cast,
    sub,
    sub_relu,
)
from .basic.vec_binary_scalar import (
    adds,
    leaky_relu,
    maxs,
    mins,
    muls,
    shift_left,
    shift_right,
)
from .basic.vec_duplicate import duplicate
from .basic.vec_brcb import brcb
from .basic.vec_gather import gather, gatherb
from .basic.vec_gather_mask import gather_mask, get_gather_mask_remain_count
from .basic.proposal import (
    proposal_concat,
    proposal_extract,
)
from .basic.vec_reduce import (
    block_reduce_sum, 
    block_reduce_max,
    block_reduce_min,
    pair_reduce_sum,
    reduce_max, 
    reduce_min,
    reduce_sum,
    repeat_reduce_sum,
    whole_reduce_max,
    whole_reduce_min,
    whole_reduce_sum,
)   
from .basic.vec_scatter import scatter
from .basic.vec_ternary_scalar import axpy
from .basic.vec_unary import (
    abs,
    exp,
    ln,
    bitwise_not,
    reciprocal,
    relu,
    rsqrt,
    sqrt,
)
from .basic.vec_vconv import (
    add_relu_cast,
    sub_relu_cast,
    set_deq_scale,
    cast_deq,
)

# core
from .core.array import array
from .core.constexpr import ConstExpr
from .core.dtype import (
    DataType,
    void,
    int8,
    int16,
    int32,
    int64,
    float16,
    float32,
    float64,
    uint8,
    uint16,
    uint32,
    uint64,
    int_,
    half,
    float_,
    double,
)
from .core.enums import (
    AippInputFormat,
    BlockMode,
    CacheLine,
    CacheMode,
    CacheRwMode,
    CubeFormat,
    DataFormat,
    DcciDst,
    DeqScale,
    GatherMaskMode,
    HardEvent,
    PipeID,
    MemDsbT,
    TPosition,
    pad_t,
    ReduceOrder,
    RoundMode,
    TransposeType,
    BatchMode,
    IterateMode,
    IterateOrder,
    ScheduleType,
    LayoutMode,
    MaskMode,
    QuantModes,
    MatmulConfigMode,
)
from .core.ir_value import GlobalAddress
from .core.ops import inline, number
from .core.properties import (
    property,
    DEFAULT_C0_SIZE,
    ONE_BLK_SIZE,
    TOTAL_L0C_SIZE,
    TOTAL_L1_SIZE,
)
from .core.range import range, static_range
from .core.tensor import GlobalTensor, LocalTensor, LocalTensorAuto
from .core.types import (
    BinaryRepeatParams,
    BrcbRepeatParams,
    CopyRepeatParams,
    DataCopyParams,
    DataCopyEnhancedParams,
    DataCopyExtParams,
    DataCopyPadExtParams,
    DataCopyPadParams,
    GatherMaskParams,
    GatherRepeatParams,
    Nd2NzParams,
    ShapeInfo,
    SliceInfo,
    TransDataTo5HDParams,
    TransposeParamsExt,
    UnaryRepeatParams,
    Nd2NzParams,
    Nz2NdParamsFull,
    DataCopyCO12DstParams,
)
from .core.aipp_types import (
    AippParams,
    AippPaddingParams,
    AippSwapParams,
    AippSingleLineParams,
    AippDataTypeConvParams,
    AippChannelPaddingParams,
    AippColorSpaceConvParams,
)
from .core.utils import static_assert, ceildiv

# fwk
from .fwk.tpipe import TBuf, TBufPool, TPipe, TQue, TQueBind, get_tpipe_ptr

__all__ = [
    # .language
    "adv",
    "basic",
    "core",
    "fwk",
]

__all__.extend(basic_all)
__all__.extend(core_all)
__all__.extend(fwk_all)
